import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import monacoEditor from 'vite-plugin-monaco-editor'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    vueJsx(),
    (monacoEditor as any).default({
      languages: ['javascript', 'css', 'json'], // 只加载需要的语言
      features: ['coreCommands', 'find'] // 仅加载必要的编辑器特性
    })
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  },
  css: {
    preprocessorOptions: {
      less: {
        javascriptEnabled: true
      }
    }
  },
  server: {
    port: 4000,
    proxy: {
      '/q-plant': {
        target: 'https://qplant-test.nioint.com',
        changeOrigin: true
      }
    }
  }
})
